package com.demo.controller;

import com.demo.bean.UnionPayRequest;
import com.demo.util.Generator;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author xyd
 * @version V1.0
 * @Package com.demo.controller
 * @Description:
 * @date 2018/8/30 12:11
 */
public class ok {
    public static void main(String[] args) {
        UnionPayRequest unionPayRequest = new UnionPayRequest();

        unionPayRequest.setMerId("777290058162715");
        unionPayRequest.setOrderId(Generator.generateOrderCode());
        unionPayRequest.setTxnAmt("1");
        unionPayRequest.setTxnTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date().getTime()));
        unionPayRequest.setPayTimeout(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date().getTime() + 15 * 60 * 1000));

        Map<String, String> requestData = new HashMap<String, String>();
        try {
            requestData = BeanUtils.describe(unionPayRequest);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

        System.out.println(requestData);
    }
}
